<template>
  <div>

    <el-dialog
      :visible.sync="openTwo"
      width="30%"
      center>
      <el-image :src="this.srcList"></el-image>
    </el-dialog>

    <el-card>
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
        <el-form-item label="订单状态" prop="voucherType">
          <el-select v-model="queryParams.voucherType" placeholder="请选择审核状态" clearable size="small">
            <el-option label="未审核" value="0"/>
            <el-option label="已审核" value="1"/>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-table v-loading="loading" :data="infoList" >
        <el-table-column label="订单编号" align="center" prop="orderSn" />
        <el-table-column label="下单人" align="center" prop="customerName" />
<!--        <el-table-column label="收货人姓名" align="center" prop="shippingUser" />-->
        <el-table-column label="地址" align="center" prop="address1" />
<!--        <el-table-column label="支付方式" align="center" prop="paymentMethod" >-->
<!--          <template slot-scope="scope">-->
<!--            {{scope.row.paymentMethod=='1' ? '支付宝' : scope.row.paymentMethod=='2' ? '微信' : '线下'}}-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column label="优惠金额" align="center" prop="districtMoney" />

        <el-table-column label="上传凭证" width="200" align="center" prop="orderVoucherUrl" >
          <template slot-scope="scope">
            <div @click="aaa(scope.row)">
              <el-image
                style="width: 100px; height: 100px"
                :src="scope.row.orderVoucherUrl">
              </el-image>
            </div>
          </template>
        </el-table-column>

        <el-table-column label="运费金额" align="center" prop="shippingMoney" />
        <el-table-column label="支付金额" align="center" prop="paymentMoney" />
        <el-table-column label="下单时间" align="center" prop="createTime1">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime1, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="订单状态" align="center" prop="orderStatus" >
          <template slot-scope="scope">
            {{scope.row.orderStatus=='1' ? '待付款' : scope.row.orderStatus=='2' ? '待发货' : scope.row.orderStatus=='3' ? '待收货' : scope.row.orderStatus=='4' ? '已收货' : scope.row.orderStatus=='5' ? '交易取消' : scope.row.orderStatus=='6' ? '删除订单' : scope.row.orderStatus=='7' ? '取消订单'  : scope.row.orderStatus=='8' ? '退货' : scope.row.orderStatus=='9' ? '换货' : '待审核'}}
          </template>
        </el-table-column>
<!--        <el-table-column label="分类名称" align="center" prop="categoryName" />-->
        <el-table-column label="商品名称" align="center" prop="productName" />
        <el-table-column label="店铺名称" align="center" prop="shopsName" />
        <el-table-column label="商品类别" align="center" prop="categoryType" >
          <template slot-scope="scope">
            <el-tag
              :type="scope.row.categoryType === '0' ? 'success' : 'warning'"
              disable-transitions>{{scope.row.categoryType ==='0' ? '建房主材类别' : '家居建材类别'}}</el-tag>
          </template>
        </el-table-column>
<!--        <el-table-column label="店铺类型" align="center" prop="supplierTypeform" >-->
<!--          <template slot-scope="scope">-->
<!--            <el-tag-->
<!--              :type="scope.row.supplierTypeform === '1' ? 'success' : 'warning'"-->
<!--              disable-transitions>{{scope.row.supplierTypeform ==='1' ? '物品' : '技术'}}</el-tag>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-if="scope.row.voucherType == '0'"
            >审核</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>

  </div>
</template>

<script>
  import { getOfflineOrderList,updateOrderVoucher } from "@/api/super/offlineOrder";

  export default {
    data(){
      return{
        srcList:['',],
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 商品图片信息表格数据
        infoList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        openTwo:false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          productId: null,
          picDesc: null,
          picUrl: null,
          isMaster: null,
          picOrder: null,
          picStatus: null,
          modifiedTime: null,
          voucherType:null,
        },
      }
    },
    created() {
      this.getList();
    },
    methods: {

      aaa(row){
        this.openTwo = true;
        this.srcList = row.orderVoucherUrl
      },

      getList(){
        this.loading = true;
        getOfflineOrderList(this.queryParams).then(res=>{
          this.infoList = res.rows;
          this.total = res.total;
          this.loading = false;
          console.log(this.infoList);
        })
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      handleUpdate(row){
        console.log(row.orderVoucherId);
        const orderMasterId = row.orderSn;
        this.$confirm('是否通过编号为"' + orderMasterId + '"的线下支付审核?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return updateOrderVoucher(row.orderVoucherId);
        }).then(() => {
          this.getList();
          this.msgSuccess("审核成功");
        }).catch(function() {});
      }
    }
  }
</script>

<style scoped>

</style>
